package org.fast.project.common.utils;

/**
 * @author : lilith·bristol
 * @program : spring-web-archetype-utils
 * @description : 线程本地变量工具类
 * @date : 2019-06-01 18:25
 **/

public class ThreadLocalUtil {

    private static <T> ThreadLocal<T> getInstance(T clazz) {
        return ThreadLocal.withInitial(() -> {
            Object o = new Object();
            return (T) o;
        });
    }

    public static <T> void add(T value, ThreadLocal<T> local) {
        local.set(value);
    }

    public static <T> T getId(ThreadLocal<T> local) {
        return local.get();
    }

    public static <T> void remove(ThreadLocal<T> local) {
        local.remove();
    }
}
